﻿using Supermarket;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace XLSupermarket.Financial.Income_details
{
    public partial class Income_detailsForm : Form
    {
        public Income_detailsForm()
        {
            InitializeComponent();
        }
        

        

        private void button1_Click(object sender, EventArgs e)
        {
            string Order_Number = this.textBox1.Text;
            string sql = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 " +
                "from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od " +
                "where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and s.Order_Number like'%{0}%';", Order_Number);
            this.dataGridView3.DataSource = DBHelper.FillData(sql);
        }

        

        private void Print_formbutton_Click(object sender, EventArgs e)
        {
            ExportToExcel d = new ExportToExcel();
            d.OutputAsExcelFile(dataGridView3);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string Order_Number = this.textBox1.Text;
            string date1 = this.dateTimePicker1.Value.ToString("yyyy-MM-dd");
            string date2 = this.dateTimePicker2.Value.ToString("yyyy-MM-dd");
            string sql = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw, Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and s.Order_Number like'%{0}%' and Time_Of_Sale > '{1}' and Time_Of_Sale < '{2}'", Order_Number, date1, date2);
            this.dataGridView3.DataSource = DBHelper.FillData(sql);
        }
    }
}
